<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 
      

<h:head></h:head> 
<body> 
<p:layout fullPage="true" style="margin-right:70px;margin-bottom:80px;">

<p:layoutUnit id="right" position="east" collapsible="true"
                 header="Geo News" resizable="true" closable="false" style="text-align:justify;"  >

                 
         		
         							                              								 
	
                      	<h:form name="frm1" >
							<h:panelGrid columns="2">
							<h:inputHidden id="lat" name="lat" value="#{noticiaController.lat}" />
							 <h:inputHidden id="lng" name="lng" value="#{noticiaController.lng}" />
						
							<h:outputLabel for="titulo" value="Titulo:" />
							<p:inputText id="titulo" 
								 required="true" value="#{noticiaController.id}">
								<f:validateLength minimum="2" />
							</p:inputText>
											
						
							
							<h:outputLabel for="subtitulo" value="Subtitulo:" />
							<p:inputText id="subtitulo" 
							 required="true" value="#{noticiaController.titulo}"/>	
							 					
				
							
							<h:outputLabel for="descricao" value="Descrição:"/>
						
							<p:inputTextarea rows="3" cols="25" id="descricao" value="#{noticiaController.texto}" />			
						
							
							<h:outputLabel for="imagem" value="Imagem:"/>						
							   <p:fileUpload value="#{fileUploadController.file}" mode="simple" /> 
							                 			
               			 
               				<h:outputLabel for="links" value="Links:"/>
               		
   
							<p:inputText id="link1" 
							 required="false"  />
						
							<p:inputText id="link2" 
							 required="false" />
							 
							<p:inputText id="link3" 
							 required="false"  />
				
												            
							</h:panelGrid>
						
										<p:commandButton value="Criar Noticia" ajax="false"  action="#{noticiaController.salvar}" oncomplete="limpar()" />
											
							</h:form>
				<script type="text/javascript">
											function limpar(){
												  document.forms[0].elements[3].value="salvo";
												
											}
			</script>		
 

      
                </p:layoutUnit>	
                <p:layoutUnit id="center" position="center" style="height:100%;width:100%">

<p:growl id="messages" showDetail="true" />

<p:gmap id="gmap" center="36.890257,30.707417" zoom="13" type="HYBRID" 
	style="width:100%;height:100%"
	model="#{mapController.simpleModel}" 
	onPointClick="handlePointClick(event);" 
	widgetVar="map" >
	
	  				<p:ajax event="overlaySelect" listener="#{mapController.onMarkerSelect}" />
        				
        				<p:gmapInfoWindow>  
           					 <p:outputPanel style="text-align:center;display:block;margin:auto:">  
 								<h:form>
 								<h:commandLink action="interface" value="#{mapController.marker.title}" />
 								<f:param ></f:param>
 								</h:form> 								 
            				</p:outputPanel> 
  
        				</p:gmapInfoWindow> 
	 
        			
	</p:gmap>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
		var currentMarker = null;
									
		function handlePointClick(event) {
			if(currentMarker == null) {
				    document.forms[0].elements[0].value = event.latLng.lat();
				    document.forms[0].elements[1].value = event.latLng.lat();
					document.forms[0].elements[2].value = event.latLng.lng();
					
					currentMarker = new google.maps.Marker({
					position:new google.maps.LatLng(event.latLng.lat(), event.latLng.lng())
					});
					map.addOverlay(currentMarker);
					}	
		}

</script>			
	
</p:layoutUnit>
</p:layout>
</body> 
</html>
